#include <stdio.h>
#define  N   10
void InputMatrix(int a[N][N], int n);
int AddDiagonal(int a[N][N], int n);
int main()
{		 	   
    int a[N][N], n, sum;
    printf("Input n:");
    scanf("%d", &n);//1
    InputMatrix(a, n);//1
    sum = AddDiagonal(a, n);//1
    printf("sum = %d\n", sum);//1
    return 0;
}		 	   
void InputMatrix(int a[N][N], int n)
{		 	   
    int i, j;
    printf("Input %d*%d matrix:\n", n, n);//1
    for (i = 0; i < n; i++)//1
    {		 	   
        for (j = 0; j < n; j++)//1
        {		 	   
            scanf("%d", &a[i][j]);//1
        }
    }
}		 	   
int AddDiagonal(int a[N][N], int n)
{		 	   
    int i, j, sum = 0;//1
    for (i = 0; i < n; i++)//1
    {		 	   
        for (j = 0; j < n; j++)//1
        {		 	   
            if (i == j || i + j == n - 1)//1
                sum = sum + a[i][j];//1
        }
    }
    return sum;//1
}		